Skip to content

this change allows to force the compiler to put the code of a functio…#11

Merged
WinterMute merged 1 commit into
devkitPro:masterfrom
maraflush:add-thumb-arm-attributes-change-the-cpu-code
Jan 14, 2024
Merged

this change allows to force the compiler to put the code of a functio…#11
WinterMute merged 1 commit into
devkitPro:masterfrom
maraflush:add-thumb-arm-attributes-change-the-cpu-code

Conversation

@maraflush
Copy link
Copy Markdown
Contributor

Hello,

Sometimes, I need to change my code with thumb or arm mode for specific usage.
These attributes can help for us.

Regards,

@DacoTaco
Copy link
Copy Markdown
Member

looking at this ive started to get confused how this all works.
online i can only find examples that set the target without the . in the name, and ive been using the same in starstruck.
'.arm' or '.thumb' also works?

@maraflush
Copy link
Copy Markdown
Contributor Author

Yes, you can force the compiler to use thumb or arm with this update like

THUMB_CODE u16 sum_function() {
  u16 i;
  u16 sum = 0;
  for (i = 0 ; i < 10 ; i++) {
    sum += 1;
  }
  return sum;
}

@maraflush
Copy link
Copy Markdown
Contributor Author

looking at this ive started to get confused how this all works.
online i can only find examples that set the target without the . in the name, and ive been using the same in starstruck.
'.arm' or '.thumb' also works?

How you use this .arm and .thumb in C code ?

@LunarLambda
Copy link
Copy Markdown
Contributor

It's target("arm") and target("thumb"). See GCC ARM function attributes and libseven's macros.

@DacoTaco
Copy link
Copy Markdown
Member

DacoTaco commented Dec 27, 2021

It's target("arm") and target("thumb"). See GCC ARM function attributes and libseven's macros.

^this is what i meant^
https://github.com/DacoTaco/StarStruck/blob/master/kernel/source/scheduler/threads.c#L139-L140
(and i know this works because its executing arm only instructions and the project is set to build as thumb unless specified otherwise)

@maraflush
Copy link
Copy Markdown
Contributor Author

ah ok ! thanks !

@maraflush
Copy link
Copy Markdown
Contributor Author

it's better thanks.

@WinterMute WinterMute force-pushed the add-thumb-arm-attributes-change-the-cpu-code branch from b68793f to cb0bee7 Compare January 14, 2024 23:09
this change allows to force the compiler to put the code of a function in thumb or arm mode.
@WinterMute WinterMute force-pushed the add-thumb-arm-attributes-change-the-cpu-code branch from cb0bee7 to eda685a Compare January 14, 2024 23:12
@WinterMute WinterMute merged commit 755c7e4 into devkitPro:master Jan 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants